package com.monitor.action.user;

import java.io.PrintWriter;

import com.monitor.action.MonitorActionSupport;
import com.monitor.po.EnvironmentRecord;
import com.monitor.service.EnvironmentRecordService;
import com.monitor.util.Constants;
import com.monitor.util.Pager;

public class EnvironmentRecordAction extends MonitorActionSupport {

	private static final long serialVersionUID = 7359311710777093278L;
	private long uid;
	private EnvironmentRecordService environmentRecordService;
	private int cPage;
	private Pager<EnvironmentRecord> records;
	private int eid;

	@Override
	public String execute() throws Exception {
		cPage = cPage < 1 ? 1 : cPage;
		long _uid = getUid(uid);
		records = environmentRecordService.getEnvironmentRecordByUid(_uid, Constants.DEFAULT_PAGESIEZE, cPage);
		return SUCCESS;
	}

	public void deleteEnvRecord() throws Exception {
		long _uid = getUid(uid);
		PrintWriter out = getWriter();
		boolean success = environmentRecordService.deleteEnvironmentRecord(_uid, eid);
		if (success) {
			out.print("success");
		} else {
			out.print("failed");
		}
		out.flush();
		out.close();
	}

	public long getUid() {
		return uid;
	}

	public void setUid(long uid) {
		this.uid = uid;
	}

	public EnvironmentRecordService getEnvironmentRecordService() {
		return environmentRecordService;
	}

	public void setEnvironmentRecordService(EnvironmentRecordService environmentRecordService) {
		this.environmentRecordService = environmentRecordService;
	}

	public int getcPage() {
		return cPage;
	}

	public void setcPage(int cPage) {
		this.cPage = cPage;
	}

	public Pager<EnvironmentRecord> getRecords() {
		return records;
	}

	public void setRecords(Pager<EnvironmentRecord> records) {
		this.records = records;
	}

	public int getEid() {
		return eid;
	}

	public void setEid(int eid) {
		this.eid = eid;
	}

}
